package com.wwwc.index.web.servlet;

import java.util.Properties;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import java.net.URL;

//import com.wwwc.util.web.httpConnecter;

public class ParseXML{

    private Properties props;
    /*
    public void parseXmlValue(String xml_url) {
	XmlValueParser handler   = null;
	SAXParserFactory factory = null;
	SAXParser parser         = null;

	try {
	    handler = new XmlValueParser();
	    factory = SAXParserFactory.newInstance();
	    factory.setNamespaceAware(false);
	    factory.setValidating(false);
	    parser = factory.newSAXParser();

	    parser.parse(xml_url, handler); 
	    handler.printout();
	}
	catch (Exception e) {
	    System.out.println("ParseXML:Error:"+e);
	}
	finally{
	    factory=null;
	    parser=null;
	    handler=null;
	}
    }
    */

    public void parseConfig(String xml_url) {
	ConfigParser handler     = null;
	SAXParserFactory factory = null;
	SAXParser parser         = null;

	try {
	    handler = new ConfigParser();
	    factory = SAXParserFactory.newInstance();
	    factory.setNamespaceAware(false);
	    factory.setValidating(false);
	    parser = factory.newSAXParser();

	    //String url = "http://rss.news.yahoo.com/rss/topstories";
	    //URL confURL = org.jboss.system.JBossRMIClassLoader.getResource("filename");
	    //StringBuffer sbf = (new httpConnecter()).getReturn(xml_url);
 
	    parser.parse(xml_url, handler); 
	    props = handler.getProps();
	}
	catch (Exception e) {
	    System.out.println("ParseXML:Error:"+e);
	}
	finally{
	    factory=null;
	    parser=null;
	    handler=null;
	}
    }

    public Properties getProps() {
	return this.props;
    }
}
